package com.yoona.system.controller;



import com.yoona.common.auth.CheckLogin;
import com.yoona.common.response.BaseResponse;
import com.yoona.system.dto.WriteCommentsDto;
import com.yoona.system.service.IDynamicCommentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Email: m15602498163@163.com
 * @Author: yoonada
 * @Date: 2020/9/21
 * @Time: 8:44 下午
 * @Msg:
 */
@Api(tags = "动态评论")
@CrossOrigin
@RestController
@RequestMapping("/dynamic-comments")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DynamicCommentsController {

    private final IDynamicCommentsService dynamicCommentsService;

    @CheckLogin
    @ApiOperation("写评论")
    @PostMapping("/writeComments")
    public BaseResponse<Object> writeComments(@RequestBody WriteCommentsDto writeCommentsDto){
        return dynamicCommentsService.writeComments(writeCommentsDto);
    }

    @CheckLogin
    @ApiOperation("是否能够删除这条评论")
    @GetMapping("/whetherCanDeleteThisComments")
    public BaseResponse<Object> whetherCanDeleteThisComments(String commentId){
        return dynamicCommentsService.whetherCanDeleteThisComments(commentId);
    }

    @CheckLogin
    @ApiOperation("删除评论")
    @PostMapping("/deleteComments")
    public BaseResponse<Object> deleteComments(String commentId,String dynamicId){
        return dynamicCommentsService.deleteComments(commentId,dynamicId);
    }



}
